package icu.d4peng.basic.core.json;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;

import java.time.ZoneId;
import java.util.Locale;
import java.util.TimeZone;

/**
 * JacksonMapper:自定义的ObjectMapper子类
 *
 * @author d4peng <a href="d4peng@qq.com">d4peng@qq.com</a>
 * @since 2023.12.02
 */
public class JacksonMapper extends ObjectMapper {

	public JacksonMapper() {
		super();
		this.registerModule(new JacksonModule())
			.setLocale(Locale.CHINA)
			.setTimeZone(TimeZone.getTimeZone(ZoneId.systemDefault()))
			// 忽略null值
			// .setSerializationInclusion(JsonInclude.Include.NON_NULL)
			// 美化输出
			.enable(SerializationFeature.INDENT_OUTPUT)
			// 排序Map
			.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
	}

}
